package com.jl.jlapp.mvp.activity;

import android.app.ProgressDialog;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;

import butterknife.BindView;
import butterknife.ButterKnife;

import com.jl.jlapp.R;
import com.jl.jlapp.adapter.TracingListAdapter;
import com.jl.jlapp.eneity.OrderStateDetailModel;
import com.jl.jlapp.eneity.OrderStateDetailModel.ResultDataBean;
import com.jl.jlapp.nets.Api;
import com.jl.jlapp.nets.CommonObserver;
import com.jl.jlapp.nets.Net;
import com.jl.jlapp.nets.Transformer;
import com.jl.jlapp.utils.CustomLanearLayoutManager;

import io.reactivex.Flowable;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.schedulers.Schedulers;

import java.util.List;

public class OrderTracingActivity
        extends AppCompatActivity {
    @BindView(R.id.back)
    ImageView back;
    List<OrderStateDetailModel.ResultDataBean> dataList;
    int orderId = -1;
    @BindView(R.id.order_state)
    TextView order_state;
    private ProgressDialog progressDialog;
    @BindView(R.id.recyclerView)
    RecyclerView recyclerView;
    TracingListAdapter tracingListAdapter;
    int userId = -1;

    private void init() {
        this.back.setOnClickListener(new OnClickListener() {
            public void onClick(View paramAnonymousView) {
                OrderTracingActivity.this.finish();
            }
        });
        String str = getIntent().getStringExtra("orderState");
        this.order_state.setText(str);
        initData();
    }

    private List<OrderStateDetailModel.ResultDataBean> initData() {
        if ((this.orderId != -1) && (this.userId != -1)) {
            Net.get().getOrderStateDetail(this.orderId, this.userId)
                    .compose(Transformer.<OrderStateDetailModel>switchSchedulers())
                    .subscribe(new CommonObserver<OrderStateDetailModel>() {
                        @Override
                        protected void onError(String errorMsg) {

                        }

                        @Override
                        protected void onSuccess(OrderStateDetailModel orderStateDetailModel) {

                        }
                    });
        } else {
            if (this.userId == -1) {
                startActivity(new Intent(this, LoginActivity.class));
            } else if (this.orderId == -1) {
                Toast.makeText(this, "页面传值没有接收到", Toast.LENGTH_SHORT).show();
            }
        }
        return this.dataList;
    }


    public void buildProgressDialog() {
        if (this.progressDialog == null) {
            this.progressDialog = new ProgressDialog(this);
            this.progressDialog.setProgressStyle(0);
        }
        this.progressDialog.setMessage("加载中");
        this.progressDialog.setCancelable(true);
        this.progressDialog.show();
    }

    public void cancelProgressDialog() {
        if ((this.progressDialog != null) && (this.progressDialog.isShowing())) {
            this.progressDialog.dismiss();
        }
    }

    protected void onCreate(Bundle paramBundle) {
        super.onCreate(paramBundle);
        setContentView(R.layout.order_tracing_activity);
        ButterKnife.bind(this);
    }

    protected void onResume() {
        super.onResume();
        this.userId = getSharedPreferences("JLAppData", 0).getInt("userId", -1);
        buildProgressDialog();
        this.orderId = getIntent().getIntExtra("orderId", -1);
        init();
    }

    public void setAdapter() {
        CustomLanearLayoutManager localCustomLanearLayoutManager = new CustomLanearLayoutManager(this);
        localCustomLanearLayoutManager.setScrollEnabled(false);
        this.recyclerView.setLayoutManager(localCustomLanearLayoutManager);
        this.tracingListAdapter = new TracingListAdapter(R.layout.tracing_list_item, this.dataList);
        this.recyclerView.setAdapter(this.tracingListAdapter);
    }
}


/* Location:              /Users/davidzhang/Documents/decompileApk/jlfood-dex2jar.jar!/com/jl/jlapp/mvp/activity/OrderTracingActivity.class
 * Java compiler version: 6 (50.0)
 * JD-Core Version:       0.7.1
 */